"""
检查作业完成度
TODO: 使用 CI 自动检查
"""
import csv
import os

classrooms = ["22-7", "22-8", "22-9", "22-10"]


def check() -> list[tuple]:
    check_list = []
    with open("all_students.csv", "r") as f:
        reader = csv.reader(f)
        next(reader)
        for row in reader:
            checked = False
            _, classroom, sid, name, *_ = row
            classroom = classroom.replace("软件", "")
            if classroom not in classrooms:
                continue
            if os.path.exists(f"{classroom}/{sid}_{name}.txt"):
                checked = True
            check_list.append((classroom, sid, name, checked))

    check_list.sort(key=lambda x: (int(x[0].split("-")[-1])))
    return check_list


if __name__ == "__main__":
    check_list = check()
    for c in check_list:
        print(",".join(map(str, c)))
